//
//  HWStoneScissorClothViewController.m
//  HuaWan
//
//  Created by HuaWan on 2023/10/22.
//  Copyright © 2023 HuaWan. All rights reserved.
//

#import "HWStoneScissorClothViewController.h"

#import "HWStoneScissorClothSelectButtonCell.h"

#import "HWSinglePersonViewController.h"

@interface HWStoneScissorClothViewController ()

@end

@implementation HWStoneScissorClothViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib
    self.view.backgroundColor = UIColorFromHex(0x000000);
    [self setNavigationItemTitleViewWithTitle:@"石头剪刀布"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"HWStoneScissorClothSelectButtonCell" bundle:nil] forCellReuseIdentifier:@"HWStoneScissorClothSelectButtonCell"];
    
    self.tableView.frame = CGRectMake(0,self.navigationBarHeight + 160, kScreenWidth,164);
    self.tableView.scrollEnabled = NO;
}

- (void)showBack {
    NSString *imageName = @"white_back";
    [self setLeftItemWithIcon:[UIImage imageNamed:imageName] selector:@selector(backAction:)];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

#pragma mark - cellDataSource

- (NSArray *)cellDataSource {
    
    if (!self.dataSource) {
        NSMutableArray *arr = [NSMutableArray arrayWithCapacity:4];
        
        __block NSMutableArray *subarr = nil;
        __block NSDictionary *dict = nil;
             
        subarr = [NSMutableArray arrayWithCapacity:1];

        dict =  @{@"class":HWStoneScissorClothSelectButtonCell.class,
                  @"height":@([HWStoneScissorClothSelectButtonCell getCellFrame:[NSNumber numberWithFloat:82]]),
                  @"data":[HWStoneScissorClothSelectButtonCellModel ittemModelWithTitle:@"单人"],
                  @"delegate":@YES};
        [subarr addObject:dict];
        
        dict =  @{@"class":HWStoneScissorClothSelectButtonCell.class,
                  @"height":@([HWStoneScissorClothSelectButtonCell getCellFrame:[NSNumber numberWithFloat:82]]),
                  @"data":[HWStoneScissorClothSelectButtonCellModel ittemModelWithTitle:@"双人"],
                  @"delegate":@YES};
        [subarr addObject:dict];

        [arr addObject:subarr];

        self.dataSource = arr;
    }
    return self.dataSource;
}

#pragma mark HWStoneScissorClothSelectButtonCellDelegate 单人 双人

- (void)stoneScissorClothSelectButtonCell:(HWStoneScissorClothSelectButtonCell *)cell button:(UIButton *)sender {
    [self gotoSinglePersonViewController:sender.titleLabel.text];
}


#pragma mark - goto

- (void)gotoSinglePersonViewController:(NSString *)type {
    HWSinglePersonViewController *vc = [HWSinglePersonViewController new];
    vc.type = type;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
